package com.student.servlet;


        import com.student.dao.StudentDao;
        import com.student.model.Student;

        import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        import java.io.IOException;
        import java.util.List;

/**
 * @author 康娜的小肥腿
 */
@WebServlet(name = "QueryStudentServlet",urlPatterns = {"/servlet/queryStudent","/query/employee"}) // urlPatterns属性与value等价
public class QueryStudentServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        Student employee = new Student();
        employee.setEname(request.getParameter("ename"));
        employee.setSno(request.getParameter("sno"));
        employee.setZy(request.getParameter("zy"));



        List<Student> list = new StudentDao().select(employee);
        // 将数据存放在request中
        request.setAttribute("employeeList", list);
        // 请求的转发，不能使用重定向
        request.getRequestDispatcher("/1.jsp").forward(request,response);
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
